package com.mybts.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 王志鹏
 * @title: Swagger2
 * @projectName baoge
 * @description: TODO
 * @date 2019/3/20 9:30
 */

/**
 * @author Ray
 * @date 2018/7/1 0001
 * Swagger2的配置文件，在项目的启动类的同级文件建立
 */

@Configuration //标记配置类
@EnableSwagger2 //开启在线接口文档
public class Swagger2 {
    /**
    *功能描述 动态生成api http://127.0.0.1:8080/swagger-ui.html
    * @author 王志鹏
    * @date 2019/7/27/17:08
    []
    * @return
    */
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_12)
                .groupName("mybatiesTestDemo")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mybts"))
                .paths(PathSelectors.any()).build();


    }

    /**
     * 设置文档信息
     */
    private ApiInfo apiInfo(){
//        Contact ss = new Contact();
//        ss.setEmail("820398513@qq.com");
//        ss.setName("wangzhipeng");
//        ss.setUrl("");
        return new ApiInfoBuilder()
                .title("mybatiesTestDemo API")
                .description("")
                .termsOfServiceUrl("")
                .contact("820398513@qq.com")
                .description("更多资料")
                .version("1.0")
                .build();
    }

}